#lang racket

(require net/url
         racket/file
         racket/runtime-path)

;; 定义临时文件路径
(define-runtime-path tmp-file "temp-module.rkt")

;; 从URL下载代码并保存到临时文件
(define (download-code url-str)
  (let* ([url (string->url url-str)]
         [port (get-pure-port url)]
         [code (port->string port)])
    (close-input-port port)
    (display-to-file code tmp-file #:exists 'replace)
	(display code)))


;; 主函数：下载并执行远程代码
(define (download-and-execute url-str)
  (download-code url-str)
  (system (format "racket ~a" tmp-file))
  (delete-file tmp-file)) ; 清理临时文件

;; 使用示例
(module+ main
  (with-handlers ([exn:fail? (λ (e) (displayln (exn-message e)))])
    (download-and-execute "https://gitee.com/wu-org/isa/raw/master/Tao5.rkt")))

